package com.atguigu.lease.web.admin.context;

/**
 * Package: com.atguigu.lease.web.admin.context
 * Description:
 *
 * @Author 比奇堡-派大星
 */

import com.atguigu.lease.model.entity.SystemUser;

public class LoginUserContext {

    //使用ThreadLocal对象时，切记销毁，因为该对象归JVM管理
    private static final ThreadLocal<SystemUser> userThreadLocal = new ThreadLocal<>();

    public static void setLoginUser(SystemUser systemUser) {
        userThreadLocal.set(systemUser);
    }

    public static SystemUser getLoginUser() {
        return userThreadLocal.get();
    }

    public static void clear() {
        userThreadLocal.remove();
    }
}

